package com.ctsi.system.domain;

import com.ctsi.commons.util.UtilDateTime;
import com.ctsi.system.workcalendar.defdate.Lunar;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Calendar;

/**
 * @author zhangjw
 * @className DayCell
 * @description
 * @date 2019/3/30 13:04
 **/
public class DayCell implements Serializable {
    private Calendar calendar;
    private SimpleDateFormat sf = new SimpleDateFormat(UtilDateTime.defaultDatePattern);
    private boolean free = false;

    public DayCell() {

    }

    public DayCell(Calendar calendar) {
        this.calendar = (Calendar) calendar.clone();
    }

    public boolean isFree() {
        return free;
    }

    public void setFree(boolean free) {
        this.free = free;
    }

    public Calendar getCalendar() {
        return calendar;
    }

    public void setCalendar(Calendar calendar) {
        this.calendar = calendar;
    }

    public String getOldCalendar() {
        if (calendar == null){
            return "";
        }
        Lunar lunar = new Lunar();
        return lunar.getLunar(getYear(), getMonth(), getDay());
    }

    public String getFormatDay() {
        if (calendar == null)
            return "";
        return sf.format(calendar.getTime());
    }

    public int getYear() {
        return calendar.get(Calendar.YEAR);
    }

    public int getMonth() {
        return calendar.get(Calendar.MONTH) + 1;
    }

    public int getDay() {
        return calendar.get(Calendar.DAY_OF_MONTH);
    }

    public int getWeekDay() {
        return calendar.get(Calendar.DAY_OF_WEEK);
    }
}
